The object serialization and remote method invocation (RMI) of Sun Microsystem's Java are becoming popular as a way of running distributed applications. Using RMI, an application can make a method call against an object residing on another machine. This allows the distribution of work across multiple machines by placing interrelated applications on different machines and using RMI calls to pass execution between the applications. In addition, RMI uses Java serialization to pass objects as parameters between the methods or objects comprising remote applications. Serialization is Java's way of "flattening" (transforming) an object into a series of bytes that can later be reassembled. "Flattening" the objects allow them to flow across a network. In the case of RMI, the bytes are reassembled ("unflattened") on a remote machine and used by the remote application. This is shown in FIG. 2 where the object (201) is "flattened" and turned into a byte stream (203) to be transmitted across the socket (205). At the destination node, the byte stream (207) is "unflattened" and reconstructed as an object (209).
Java defines a default serialization for objects such that, when a programmer specifies that an object "implements" the serializable interface, the object is given the default serialization. The programmer can override the default serialization, but the default serialization is rather efficient and overriding it is seldom necessary.
To preserve the semantics of the object being passed, and thus the semantic of the remote method invocation, Java flattens all data contained in an object into the serialized byte stream. However, any single method call (or remote method call) is unlikely to use all of the object's fields. Thus, serializing the entire object causes unnecessary bytes to flow.
If the object is serialized only for remote calls that use a common subset of the object's fields, the programmer can specify a serialization that sends only those fields. However, that methodology forces the programmer to do additional, error-prone work. Also, since in Java the programmer can specify only a single serialization, he must flatten all fields in the method even though any single method invocation may not use all of the fields. This leads to unnecessary network traffic.